package org.whut.practice.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.ResponseBody;
import org.whut.practice.pojo.Task;
import org.whut.practice.service.TaskService;
import org.whut.practice.utils.Response;


import java.util.HashMap;
import java.util.Map;
import java.util.List;

@Controller
public class TaskController {
    @Autowired
    TaskService taskService;

    @ResponseBody
    @GetMapping("/tasks")
    public Map<String, Object> getTaskList(Task task) {
        List<Task> list = taskService.selectList(task.getTid(), task.getDates(), task.getClasses(), task.getName());
        return list != null ? Response.makeOkResponse(list, "Successfully get task data") :
                Response.makeErrorResponse("Failed to get task data");
    }
}
